<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){


        $user_info=session('user_obj');
        // 不是总管理员
        if($user_info['is_admin']!=1){
            // 获取菜单列表
            $role_menu_list=M('role_menu')->where(['role_id'=>$user_info['role_id']])->select();
            $menu_list=array();
            foreach($role_menu_list as $item){
                array_push($menu_list,
                    M('menu')->where(['id'=>$item['menu_id'],'status'=>'1','show'=>1])->find()
                );
            }
            $menu_arr=array();
            foreach ($menu_list as $item){
                $menu_arr[$item['id']]=$item;
            }
            $menu_arr=sortByTwoFiled($menu_arr,'parent_id','SORT_DESC','sort','SORT_ASC');
        }else{
            // 获取菜单列表
            $menu_list=M('menu')->where(['status'=>1,'show'=>1])->order('parent_id desc,sort')->select();
            $menu_arr=array();
            foreach ($menu_list as $item){
                $menu_arr[$item['id']]=$item;
            }
        }
        $menu_tree=genTree9($menu_arr);        
        $this->assign('menu_tree',$menu_tree);
        $this->display();
    }
}